# -*- coding: utf-8 -*-
# @Author  : wyh
# @Time    : 2023/2/12 17:15
# @File    : 5操作
# @Email   : 2448979539@qq.com
import os
import django
import pandas

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
django.setup()

from django.contrib.gis.geos import Point, LinearRing
from django.contrib.gis.geos.polygon import Polygon
from django.contrib.gis.geos.collections import MultiPolygon
from world.models import WorldBorder

# 创建一个城市
sjz = WorldBorder()
sjz.name = '石家庄'
sjz.area = 932745
sjz.pop2005 = 5000000
sjz.fips = 'SJ'
sjz.iso2 = 'SJ'
sjz.iso3 = 'SJZ'
sjz.un = 105
sjz.region = 105
sjz.subregion = 1051
sjz.lon = 114.1
sjz.lat = 38.1
l1 = LinearRing((135, 28), (135, 25), (139, 25), (139, 28), (135, 28))
l2 = LinearRing(((135, 34), (135, 32), (139, 32), (139, 34), (135, 34)))

sjz.mpoly = MultiPolygon(
    Polygon(l1),
    Polygon(l2),
)
sjz.save()
